package com.qike.yuandongguoji.service;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.qike.yuandongguoji.pojo.User;
import org.springframework.stereotype.Service;

import java.util.Date;

//import com.qike.huadongexcel.pojo.ExcelUser;

/**
 * @Author: Eric.zhou
 * @Date: 2019/9/5 10:22
 */
@Service("TokenService")
public class TokenService {

    public String getToken(User user) {
        Date start = new Date();
//        long currentTime = System.currentTimeMillis() + 60* 60 * 1000*24*7;//一小时有效时间
//        Date end = new Date(currentTime);
        String token = "";

        token = JWT.create().withAudience(user.getId().toString()).withIssuedAt(start)
                .sign(Algorithm.HMAC256(user.getPwd()));
        return token;
    }
}
